package com.abbas.CayTcore.ui

import android.app.Dialog
import androidx.navigation.findNavController
import com.abbas.CayTcore.R
import com.abbas.CayTcore.base.BaseActivity
import com.abbas.CayTcore.databinding.ActivityMainUplevelBinding
import com.abbas.CayTcore.presenter.MainPresenter
import com.abbas.CayTcore.view.ViewContract

/**
 * 2.0主页
 */
class MainUplevelActivity :
    BaseActivity<ViewContract.MainActivityView, MainPresenter, ActivityMainUplevelBinding>(),
    ViewContract.MainActivityView {

    override fun getViewBinding(): ActivityMainUplevelBinding {
        return ActivityMainUplevelBinding.inflate(layoutInflater)
    }

    override fun initPresenter(): MainPresenter {
        return MainPresenter()
    }

    override fun initData() {
        presenter.firstInit()
    }

    override fun initEvent() {
//        NavigationUI.setupWithNavController(
//            binding.bnv, (supportFragmentManager
//                .findFragmentById(R.id.fragmentContainerView) as NavHostFragment).navController
//        )
        //底部导航栏切换
        binding.bnv.setOnNavigationItemSelectedListener {
            //bottomNavigation返回false将不触发点击完成
            return@setOnNavigationItemSelectedListener when(it.itemId){
                //点击主页 在多部门协作当中，这个主页要随登录账号的工作岗位变更
                R.id.home -> {
                    findNavController(R.id.fragmentContainerView).navigate(R.id.windingHomeUplevelFragment)
                    true
                }
                //用户界面
                R.id.user -> {
                    findNavController(R.id.fragmentContainerView).navigate(R.id.userHomeFragment)
                    true
                }
                else -> false
            }

        }

    }

    override fun showWaitingDialog(dialog: Dialog) {
        dialog.show()
    }

    override fun dismissDialog(dialog: Dialog) {
        dialog.dismiss()
    }


}